/**
 * @file temp.c
 * @author Derek Liu (yjkhtddx@sina.com)
 * @brief 
 * @version 0.1
 * @date 2021-02-24
 * 
 * @copyright Copyright Sci-Tech Laboratories (c) 2021
 * 
 */

#include "Target.h"

TargetStruct *createTarget(int id)
{
    TargetStruct *target = (TargetStruct *)malloc(sizeof(TargetStruct));
    target->m_id = id;
    return target;
}

int freeTarget(TargetStruct *target)
{
    do
    {
        free(target);
        target = NULL;
    } while (0);
}

int setCallback(TargetStruct *target, int (*callback)(void *, int, int), void *opaque)
{
    target->m_opaque = opaque;
    target->m_callback = callback;
    return 0;
}

int runCallback(TargetStruct *target, int data)
{
    if (!target->m_callback)
        return -1;
    return target->m_callback(target->m_opaque, target->m_id, data);
}